<template>
	<view class="page">
		<!-- // 标题点击 -->
		<view class="order-tab">
			<view class="tab" :class="{'action':OrderType==0}" @click="onOrderTab(0)">
				<text>商家消息</text>
				<text class="line"></text>
			</view>
		<!-- 	<view class="tab" :class="{'action':OrderType==1}" @click="onOrderTab(1)">
				<text>鉴定师消息</text>
				<text class="line"></text>
			</view>
			<view class="read" @click="">
				全部已读
			</view> -->

		</view>
		


		<view class="message-list">
			<view class="list" @click="onMessage(el.receiver_id,el.nav_id)" v-for="el in list">
				<view class="icon-data">
					<view class="icon">
						<image :src="el.userInfo.avatar" mode=""></image>
					</view>
					<view class="data">
						<view class="title">
							<text>{{el.userInfo.nickname}}</text>
						</view>
						<view class="describe">
							<text>{{el.msgInfo.context}}</text>
						</view>
					</view>
				</view>
				<view class="more">
					<text class="">{{el.msgInfo.create_time}}</text>
					<text v-if="!el.msgInfo.is_read" style="display:inline-block;width:10px;height:10px;background:#f00;"></text>
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	import {
		getUserMsgList,
		sendMsg,
	} from '@/config/api.js';
	export default {
		data() {
			return {
				list:[],
				OrderType: 0,
				timer: null,
			};
		},
		
		onLoad(option) {
			// this.timer = setInterval(this.initList,5000);
			this.initList();
		},
		onUnload(){
			clearInterval(this.timer)
		},
		methods: {
			initList(){
				getUserMsgList().then(res => {
					this.list =res.data;
				})
			},
			// 标题点击

			onOrderTab(type) {
				this.OrderType = type;
				// #ifdef H5
				uni.redirectTo({
					url: '/pages/MyOrderList/MyOrderList?type=' + type,
				})
				//#endif
			},
			/**
			 * 消息点击
			 * @param {String} type
			 */
			onMessage(id,nav_id) {
				// console.log(nav_id,'=====')
				// return false;
				uni.navigateTo({
					url: '/pages/DiscountsActivity/DiscountsActivity?toUserId='+id+'&nav_id='+nav_id,
				})
				// switch (type) {
				// 	case 'activity':
				// 		uni.navigateTo({
				// 			url: '/pages/DiscountsActivity/DiscountsActivity?toUserId='+id,
				// 		})
				// 		break;

				// }
			}
		}
	}
</script>

<style scoped lang="scss">
	@import 'Message.scss';
</style>